from multiprocessing import Pool, Value
from time import sleep

counter = Value('i', 0)


def f(x):
    global counter
    with counter.get_lock():
        counter.value += 1
    print("counter.value:", counter.value)
    sleep(1)
    return x
    # print(x)


if __name__ == '__main__':
    with Pool(4) as p:
        r = p.map(f, range(8))
